home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / tests / pdevtest / RCS / printStats.c,v < prev    next >
Encoding:
Text File  |  1989-10-23  |  29.3 KB  |  942 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    jhh:1.2; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     89.10.22.22.03.25;  author jhh;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     88.04.16.12.28.20;  author brent;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @Stat printing utilities
  22. @
  23.  
  24.  
  25. 1.2
  26. log
  27. @checking in Brent's changes
  28. @
  29. text
  30. @/*
  31.  * printStats.c --
  32.  *    Routines to print out program execution times, and filesystem stats.
  33.  */
  34.  
  35. #include <sprite.h>
  36. #include <status.h>
  37. #include <stdio.h>
  38. #include <proc.h>
  39. #include <vm.h>
  40. #include <kernel/fs.h>
  41. #include <kernel/fsStat.h>
  42. #include <kernel/sched.h>
  43. #include <kernel/vm.h>
  44.  
  45.  
  46.  
  47. /*
  48.  *----------------------------------------------------------------------
  49.  *
  50.  * PrintTimes --
  51.  *
  52.  *    Print the resource usage (user and kernel CPU time) and elapsed time.
  53.  *
  54.  * Results:
  55.  *    None.
  56.  *
  57.  * Side effects:
  58.  *    Prints to the specified stream
  59.  *
  60.  *----------------------------------------------------------------------
  61.  */
  62. void
  63. PrintTimes(stream, usagePtr, timePtr)
  64.     FILE *stream;
  65.     Proc_ResUsage *usagePtr;
  66.     Time *timePtr;
  67. {
  68.     Time delta;
  69.     if (usagePtr != NULL) {
  70.     Time_Add(usagePtr->userCpuUsage, usagePtr->childUserCpuUsage,
  71.                      &delta);
  72.     fprintf(stream, "%d.%03du ", delta.seconds,
  73.                    delta.microseconds / 1000);
  74.     Time_Add(usagePtr->kernelCpuUsage, usagePtr->childKernelCpuUsage,
  75.                      &delta);
  76.     fprintf(stream, "%d.%03ds ", delta.seconds,
  77.                    delta.microseconds / 1000);
  78.     }
  79.     if (timePtr != NULL) {
  80.     int seconds = timePtr->seconds;
  81.     if (seconds >= 3600) {
  82.         fprintf(stream, "%d:", seconds / 3600);
  83.         seconds = seconds % 3600;
  84.     }
  85.     if (seconds >= 60) {
  86.         fprintf(stream, "%d:", seconds / 60);
  87.         seconds = seconds % 60;
  88.     }
  89.     fprintf(stream, "%d.%03d", seconds,
  90.                    timePtr->microseconds / 1000);
  91.     }
  92.     fprintf(stream, "\n");
  93. }
  94.  
  95.  
  96. /*
  97.  *----------------------------------------------------------------------
  98.  *
  99.  * PrintIdleTime --
  100.  *
  101.  *    Given two samples sched module statistics, this computes
  102.  *    the differenc in idle ticks and, using the time, computes
  103.  *    a utilization.
  104.  *
  105.  * Results:
  106.  *    None.
  107.  *
  108.  * Side effects:
  109.  *    Prints to the specified stream
  110.  *
  111.  *----------------------------------------------------------------------
  112.  */
  113. void
  114. PrintIdleTime(stream, startSchedPtr, endSchedPtr, timePtr)
  115.     FILE *stream;
  116.     Sched_Instrument *startSchedPtr, *endSchedPtr;
  117.     Time *timePtr;
  118. {
  119.     register     highTicks;
  120.     double     lowTicks;
  121.  
  122.     Sched_Instrument zeroStats;
  123.     if (startSchedPtr == NULL) {
  124.     bzero(&zeroStats, sizeof(Sched_Instrument));
  125.     startSchedPtr = &zeroStats;
  126.     }
  127.     highTicks = endSchedPtr->processor[0].idleTicksOverflow -
  128.         startSchedPtr->processor[0].idleTicksOverflow;
  129.     lowTicks = endSchedPtr->processor[0].idleTicksLow -
  130.     startSchedPtr->processor[0].idleTicksLow;
  131.  
  132.     if (highTicks != 0) {
  133.     fprintf(stream, "(High ticks = %d)", highTicks);
  134.     }
  135.     if (timePtr->seconds == 0 && timePtr->microseconds == 0) {
  136.     fprintf(stream, "Idle ticks --/-- = 100%% Idle, Elapsed time ");
  137.     } else {
  138.     lowTicks /= 
  139.       (double)timePtr->seconds + (double) (timePtr->microseconds)*1000000.;
  140.     fprintf(stream, "Idle ticks %0.0f/%d = %6.2f%% Idle, Context Sw. %d inv %d full %d, Elapsed time ",
  141.            lowTicks,
  142.            endSchedPtr->processor[0].idleTicksPerSecond,
  143.            (double)lowTicks/
  144.            (double)endSchedPtr->processor[0].idleTicksPerSecond * 100.,
  145.            endSchedPtr->processor[0].numContextSwitches -
  146.            startSchedPtr->processor[0].numContextSwitches,
  147.            endSchedPtr->processor[0].numInvoluntarySwitches -
  148.            startSchedPtr->processor[0].numInvoluntarySwitches,
  149.            endSchedPtr->processor[0].numFullCS -
  150.            startSchedPtr->processor[0].numFullCS);
  151.     }
  152.     PrintTimes(stream, (Proc_ResUsage *)0, timePtr);
  153. }
  154.  
  155.  
  156. /*
  157.  *----------------------------------------------------------------------
  158.  *
  159.  * PrintFsStats --
  160.  *
  161.  *    Print out the filesystem statistics.  If both a start and end
  162.  *    sample of the statistics are given then the differences between
  163.  *    the two are printed.  To just print the total cumulative statistics
  164.  *    from one sample, specify a single FsStats buffer with the 'end'
  165.  *    parameter.
  166.  *
  167.  * Results:
  168.  *    None.
  169.  *
  170.  * Side effects:
  171.  *    Prints to the specified stream
  172.  *
  173.  *----------------------------------------------------------------------
  174.  */
  175. void
  176. PrintFsStats(stream, start, end, verbose)
  177.     FILE *stream;    /* Output stream */
  178.     FsStats *start;    /* 0, or address of "before run" statistics */
  179.     FsStats *end;    /* End of run statistics */
  180.     int verbose;    /* If true, everything is dumped */
  181. {
  182.     register int t1, t2, t3, t4, t5;
  183.     FsStats zeroStats;
  184.  
  185.     if (start == (FsStats *)0) {
  186.     bzero(&zeroStats, sizeof(FsStats));
  187.     start = &zeroStats;
  188.     }
  189.     /*
  190.      * Print cache size
  191.      */
  192.     fprintf(stream, "Cache blocks max %d min %d number %d/%d free %d/%d limit %d\n",
  193.                end->blockCache.maxCacheBlocks,
  194.                end->blockCache.minCacheBlocks,
  195.                start->blockCache.numCacheBlocks,
  196.                end->blockCache.numCacheBlocks,
  197.                start->blockCache.numFreeBlocks,
  198.                end->blockCache.numFreeBlocks,
  199.                end->blockCache.maxNumBlocks);
  200.  
  201.     /*
  202.      * Print bytes read traffic ratio
  203.      */
  204.     t1 = end->blockCache.bytesRead - start->blockCache.bytesRead;
  205.     t2 = end->blockCache.dirBytesRead - start->blockCache.dirBytesRead;
  206.     t3 = end->gen.remoteBytesRead - start->gen.remoteBytesRead;
  207.     t4 = end->gen.fileBytesRead - start->gen.fileBytesRead;
  208.     t5 = end->gen.physBytesRead - start->gen.physBytesRead;
  209.     fprintf(stream, "Bytes read %d+%d remote %d disk %d+%d",
  210.                t1, t2, t3, t4, t5);
  211.     if (t1 + t2 > 0) {
  212.     fprintf(stream, "\ttraffic ratio %%%d\n",
  213.                (int)((double)(t3+t4+t5)/(double)(t1+t2) * 100.));
  214.     } else {
  215.     fprintf(stream, "\n");
  216.     }
  217.  
  218.     /*
  219.      * Print bytes written traffic ratio
  220.      */
  221.     t1 = end->blockCache.bytesWritten - start->blockCache.bytesWritten +
  222.     (end->blockCache.fileDescWrites - start->blockCache.fileDescWrites +
  223.      end->blockCache.indBlockWrites - start->blockCache.indBlockWrites) *
  224.     FS_BLOCK_SIZE;
  225.     t2 = end->blockCache.dirBytesWritten - start->blockCache.dirBytesWritten;
  226.     t3 = end->gen.remoteBytesWritten - start->gen.remoteBytesWritten;
  227.     t4 = end->gen.fileBytesWritten - start->gen.fileBytesWritten;
  228.     t5 = end->gen.physBytesWritten - start->gen.physBytesWritten;
  229.     fprintf(stream, "Bytes written %d+%d remote %d disk %d+%d",
  230.                t1, t2, t3, t4, t5);
  231.     if (t1 + t2 > 0) {
  232.     fprintf(stream, "\ttraffic ratio %%%d",
  233.                (int)((double)(t3+t4+t5)/(double)(t1+t2) * 100.));
  234.     }
  235.     fprintf(stream, "\n");
  236.  
  237.     if (verbose) {
  238.     /*
  239.      * Print device bytes and zero fills
  240.      */
  241.     t1 = end->gen.deviceBytesWritten - start->gen.deviceBytesWritten;
  242.     t2 = end->gen.deviceBytesRead - start->gen.deviceBytesRead;
  243.     fprintf(stream, "Dev bytes read %d written %d\n", t1, t2);
  244.     t1 = end->blockCache.readZeroFills - start->blockCache.readZeroFills;
  245.     t2 = end->blockCache.writeZeroFills1 -
  246.         start->blockCache.writeZeroFills1;
  247.     t3 = end->blockCache.writeZeroFills2 -
  248.         start->blockCache.writeZeroFills2;
  249.     t4 = end->blockCache.fragZeroFills - start->blockCache.fragZeroFills;
  250.     fprintf(stream, "Zero Fills read %d write1 %d write2 %d frag %d\n",
  251.                    t1, t2, t3, t4);
  252.     t1 = end->blockCache.appendWrites - start->blockCache.appendWrites;
  253.     t2 = end->blockCache.overWrites - start->blockCache.overWrites;
  254.     t3 = end->blockCache.domainReadFails -
  255.         start->blockCache.domainReadFails;
  256.     fprintf(stream, "Appends %d Overwrites %d Failed Reads %d\n",
  257.                    t1, t2, t3);
  258.     }
  259.     t1 = end->blockCache.readAccesses - start->blockCache.readAccesses +
  260.      end->blockCache.fragAccesses - start->blockCache.fragAccesses +
  261.      end->blockCache.fileDescReads - start->blockCache.fileDescReads +
  262.      end->blockCache.indBlockAccesses - start->blockCache.indBlockAccesses +
  263.      end->blockCache.dirBlockAccesses - start->blockCache.dirBlockAccesses;
  264.     t2 = end->blockCache.readHitsOnDirtyBlock -
  265.     start->blockCache.readHitsOnDirtyBlock;
  266.     t3 = end->blockCache.readHitsOnCleanBlock -
  267.     start->blockCache.readHitsOnCleanBlock;
  268.     t4 = end->blockCache.fragHits - start->blockCache.fragHits +
  269.      end->blockCache.fileDescReadHits - start->blockCache.fileDescReadHits +
  270.      end->blockCache.indBlockHits - start->blockCache.indBlockHits +
  271.      end->blockCache.dirBlockHits - start->blockCache.dirBlockHits;
  272.     fprintf(stream, "Cache reads %d hits: dirty %d clean %d other %d",
  273.                t1, t2, t3, t4);
  274.     if (t1 != 0) {
  275.     fprintf(stream, "\thit ratio %%%d",
  276.                (int)((double)(t2+t3+t4)/(double)t1 * 100.));
  277.     }
  278.     fprintf(stream, "\n");
  279.  
  280.     t1 = end->blockCache.readAheads - start->blockCache.readAheads;
  281.     t2 = end->blockCache.readAheadHits - start->blockCache.readAheadHits;
  282.     t3 = end->blockCache.allInCacheCalls - start->blockCache.allInCacheCalls;
  283.     t4 = end->blockCache.allInCacheTrue - start->blockCache.allInCacheTrue;
  284.     if (t1 > 0) {
  285.     fprintf(stream, "Read Ahead: hits %d/%d all-in-cache %d/%d\n",
  286.             t2, t1, t4, t3);
  287.     }
  288.  
  289.     t1 = end->blockCache.writeAccesses - start->blockCache.writeAccesses +
  290.      end->blockCache.fileDescWrites - start->blockCache.fileDescWrites +
  291.      end->blockCache.indBlockWrites - start->blockCache.indBlockWrites +
  292.      end->blockCache.dirBlockWrites - start->blockCache.dirBlockWrites;
  293.     t2 = end->blockCache.partialWriteHits - start->blockCache.partialWriteHits +
  294.     end->blockCache.fileDescWriteHits - start->blockCache.fileDescWriteHits;
  295.     t3 = end->blockCache.partialWriteMisses -
  296.     start->blockCache.partialWriteMisses;
  297.     t4 = end->blockCache.blocksWrittenThru -
  298.     start->blockCache.blocksWrittenThru;
  299.     fprintf(stream, "Cache writes %d hits %d misses %d thru %d",
  300.                t1, t2, t3, t4);
  301.     if (t1 != 0) {
  302.     fprintf(stream, "\ttraffic ratio %%%d",
  303.                (int)((double)(t3+t4)/(double)t1 * 100.));
  304.     }
  305.     fprintf(stream, "\n");
  306.     
  307.     fprintf(stream, "Write thru %d data %d indirect %d desc %d dir %d\n",
  308.                t4,
  309.                end->blockCache.dataBlocksWrittenThru -
  310.                start->blockCache.dataBlocksWrittenThru,
  311.                end->blockCache.indBlocksWrittenThru -
  312.                start->blockCache.indBlocksWrittenThru,
  313.                end->blockCache.descBlocksWrittenThru -
  314.                start->blockCache.descBlocksWrittenThru,
  315.                end->blockCache.dirBlocksWrittenThru -
  316.                start->blockCache.dirBlocksWrittenThru);
  317.     if (end->blockCache.fileDescReads > 0) {
  318.     fprintf(stream, "File descriptor reads %d hits %d writes %d hits %d\n",
  319.                    end->blockCache.fileDescReads -
  320.                    start->blockCache.fileDescReads,
  321.                    end->blockCache.fileDescReadHits -
  322.                    start->blockCache.fileDescReadHits,
  323.                    end->blockCache.fileDescWrites -
  324.                    start->blockCache.fileDescWrites,
  325.                    end->blockCache.fileDescWriteHits -
  326.                    start->blockCache.fileDescWriteHits);
  327.     }
  328.     if (end->blockCache.indBlockAccesses > 0) {
  329.     fprintf(stream, "Indirect block reads %d hits %d writes %d\n",
  330.                end->blockCache.indBlockAccesses -
  331.                start->blockCache.indBlockAccesses,
  332.                end->blockCache.indBlockHits -
  333.                start->blockCache.indBlockHits,
  334.                end->blockCache.indBlockWrites -
  335.                start->blockCache.indBlockWrites);
  336.     }
  337.     if (end->blockCache.dirBlockAccesses > 0) {
  338.     fprintf(stream, "Directory block reads %d hits %d writes %d\n",
  339.                    end->blockCache.dirBlockAccesses -
  340.                    start->blockCache.dirBlockAccesses,
  341.                    end->blockCache.dirBlockHits -
  342.                    start->blockCache.dirBlockHits,
  343.                    end->blockCache.dirBlockWrites -
  344.                    start->blockCache.dirBlockWrites);
  345.     }
  346.     if (end->blockCache.vmRequests > 0) {
  347.     fprintf(stream, "VM requests %d tried %d gave %d\n",
  348.                    end->blockCache.vmRequests -
  349.                    start->blockCache.vmRequests,
  350.                    end->blockCache.triedToGiveToVM -
  351.                    start->blockCache.triedToGiveToVM,
  352.                    end->blockCache.vmGotPage -
  353.                    start->blockCache.vmGotPage);
  354.     }
  355.     fprintf(stream, "Cache blocks created %d, alloc from free %d part %d lru %d\n",
  356.                    end->blockCache.unmapped -
  357.                    start->blockCache.unmapped,
  358.                    end->blockCache.totFree -
  359.                    start->blockCache.totFree,
  360.                    end->blockCache.partFree -
  361.                    start->blockCache.partFree,
  362.                    end->blockCache.lru -
  363.                    start->blockCache.lru);
  364.     if (end->alloc.blocksAllocated > 0) {
  365.     fprintf(stream, "Disk blocks alloc %d free %d search %d/%d hash %d\n",
  366.                    end->alloc.blocksAllocated -
  367.                    start->alloc.blocksAllocated,
  368.                    end->alloc.blocksFreed -
  369.                    start->alloc.blocksFreed,
  370.                    end->alloc.cylsSearched -
  371.                    start->alloc.cylsSearched,
  372.                    end->alloc.cylBitmapSearches -
  373.                    start->alloc.cylBitmapSearches,
  374.                    end->alloc.cylHashes -
  375.                    start->alloc.cylHashes);
  376.     fprintf(stream, "Fragments alloc %d free %d upgrade %d blocks made %d used %d, bad hints %d\n",
  377.                    end->alloc.fragsAllocated -
  378.                    start->alloc.fragsAllocated,
  379.                    end->alloc.fragsFreed -
  380.                    start->alloc.fragsFreed,
  381.                    end->alloc.fragUpgrades -
  382.                    start->alloc.fragUpgrades,
  383.                    end->alloc.fragToBlock -
  384.                    start->alloc.fragToBlock,
  385.                    end->alloc.fullBlockFrags -
  386.                    start->alloc.fullBlockFrags,
  387.                    end->alloc.badFragList -
  388.                    start->alloc.badFragList);
  389.     }
  390.     if (end->nameCache.accesses > 0) {
  391.     fprintf(stream, "Name cache entries %d accesses %d hits %d replaced %d\n",
  392.                end->nameCache.size,
  393.                end->nameCache.accesses -
  394.                start->nameCache.accesses,
  395.                end->nameCache.hits -
  396.                start->nameCache.hits,
  397.                end->nameCache.replacements -
  398.                start->nameCache.replacements);
  399.     }
  400.     fprintf(stream, "Handles %d created %d installed %d hits %d old %d version %d flush %d\n",
  401.                end->handle.exists,
  402.                end->handle.created -
  403.                start->handle.created,
  404.                end->handle.installCalls -
  405.                start->handle.installCalls,
  406.                end->handle.installHits -
  407.                start->handle.installHits,
  408.                0,
  409.                end->handle.versionMismatch -
  410.                start->handle.versionMismatch,
  411.                end->handle.cacheFlushes -
  412.                start->handle.cacheFlushes);
  413.     fprintf(stream, "\tfetched %d hits %d released %d locks %d/%d wait %d\n",
  414.                end->handle.fetchCalls -
  415.                start->handle.fetchCalls,
  416.                end->handle.fetchHits -
  417.                start->handle.fetchHits,
  418.                end->handle.release -
  419.                start->handle.release,
  420.                end->handle.locks -
  421.                start->handle.locks,
  422.                end->handle.locks -
  423.                start->handle.locks,
  424.                end->handle.lockWaits -
  425.                start->handle.lockWaits);
  426.     fprintf(stream, "Segments fetched %d hits %d\n",
  427.                end->handle.segmentFetches -
  428.                start->handle.segmentFetches,
  429.                end->handle.segmentHits -
  430.                start->handle.segmentHits);
  431.     fprintf(stream, "Lookup relative %d absolute %d redirect %d found %d loops %d timeouts %d stale %d\n",
  432.                end->prefix.relative -
  433.                start->prefix.relative,
  434.                end->prefix.absolute -
  435.                start->prefix.absolute,
  436.                end->prefix.redirects -
  437.                start->prefix.redirects,
  438.                end->prefix.found -
  439.                start->prefix.found,
  440.                end->prefix.loops -
  441.                start->prefix.loops,
  442.                end->prefix.timeouts -
  443.                start->prefix.timeouts,
  444.                end->prefix.stale -
  445.                start->prefix.stale);
  446. }
  447.  
  448.  
  449. /*
  450.  *----------------------------------------------------------------------
  451.  *
  452.  * PrintVmStats --
  453.  *
  454.  *    Print out VM statistics.  If both a start and end
  455.  *    sample of the statistics are given then the differences between
  456.  *    the two are printed.  To just print the total cumulative statistics
  457.  *    from one sample, specify a single VmStats buffer with the 'end'
  458.  *    parameter.
  459.  *
  460.  * Results:
  461.  *    None.
  462.  *
  463.  * Side effects:
  464.  *    Prints to the specified stream
  465.  *
  466.  *----------------------------------------------------------------------
  467.  */
  468. void
  469. PrintVmStats(stream, start, end)
  470.     FILE *stream;    /* Output stream */
  471.     Vm_Stat *start;    /* 0, or address of "before run" statistics */
  472.     Vm_Stat *end;    /* End of run statistics */
  473. {
  474.     register    int    *diffPtr;
  475.     register    int    *startPtr;
  476.     register    int    *endPtr;
  477.     int            i;
  478.     int            inusePages;
  479.     int            totPages;
  480.     int            numModifiedPages;
  481.     Vm_Stat        diffStat;
  482.     int            totPercent;
  483.     int            totFaults;
  484.     int            heapPercent;
  485.     int            stkPercent;
  486.     int            quickPercent;    
  487.     int            totHits;
  488.     int            totPrefetches;
  489.     int            hitPct;
  490.  
  491.     startPtr = (int *)start;
  492.     endPtr = (int *)end;
  493.     diffPtr = (int *)&diffStat;
  494.  
  495.     for (i = 0; 
  496.          i < sizeof(Vm_Stat) / sizeof(int); 
  497.      i++, startPtr++, endPtr++, diffPtr++) {
  498.     *diffPtr = *endPtr - *startPtr;
  499.     }
  500.  
  501.     (void)Vm_Cmd(VM_COUNT_DIRTY_PAGES, &numModifiedPages);
  502.     fprintf(stream, "Kernel VM Pages: %d (Code+Data=%d Stacks=%d)\n",
  503.          end->kernMemPages + end->kernStackPages,
  504.          end->kernMemPages, end->kernStackPages);
  505.     inusePages = end->numDirtyPages + end->numUserPages;
  506.     totPages = end->numFreePages + inusePages;
  507.     fprintf(stream, "User VM Pages:   %d (Free=%d Dirty=%d Res=%d Alloc-list=%d)\n",
  508.         end->numFreePages + end->numDirtyPages + 
  509.         end->numReservePages + end->numUserPages, 
  510.         end->numFreePages, end->numDirtyPages,
  511.         end->numReservePages,
  512.         end->numUserPages);
  513.     fprintf(stream, "Modified pages: Total=%d %%Tot-dirty=%0.2f %%Inuse-dirty=%0.2f\n",
  514.         numModifiedPages,
  515.         (float) (numModifiedPages) / (float)totPages * 100.0,
  516.         (float) (numModifiedPages) / (float)inusePages * 100.0);
  517.     fprintf(stream, "FS Pages: Current=%d Max=%d Min=%d\n", 
  518.         end->fsMap - end->fsUnmap, end->maxFSPages, end->minFSPages);
  519.     fprintf(stream,
  520.          "Faults: %8d (Zero=%d FS=%d Swap=%d Quick=%d Coll=%d)\n", 
  521.          diffStat.totalFaults, diffStat.zeroFilled, diffStat.fsFilled,
  522.          diffStat.psFilled,diffStat.quickFaults, diffStat.collFaults);
  523.     fprintf(stream, "        %8d (Code=%d Heap=%d Stack=%d)\n", 
  524.          diffStat.totalFaults, diffStat.codeFaults, diffStat.heapFaults,
  525.          diffStat.stackFaults);
  526.     fprintf(stream, 
  527.         "Mod page stats:  Pot-mod=%d Not-mod=%d Not-hard-mod=%d\n",
  528.         diffStat.potModPages, diffStat.notModPages, 
  529.         diffStat.notHardModPages);
  530.  
  531.     /*
  532.      * Copy on write. 
  533.      */
  534.     totPages = diffStat.numCOWStkPages + diffStat.numCOWHeapPages;
  535.     totFaults = diffStat.numCOWStkFaults + diffStat.numCOWHeapFaults;
  536.     if (diffStat.numCOWHeapPages > 0) {
  537.     heapPercent = 100.0 * ((float)diffStat.numCOWHeapFaults / 
  538.                       diffStat.numCOWHeapPages);
  539.     } else {
  540.     heapPercent = 0;
  541.     }
  542.     if (diffStat.numCOWStkPages > 0) {
  543.     stkPercent = 100.0 * ((float)diffStat.numCOWStkFaults / 
  544.                       diffStat.numCOWStkPages);
  545.     } else {
  546.     stkPercent = 0;
  547.     }
  548.     if (totPages > 0) {
  549.     totPercent = 100.0 * ((float)totFaults / totPages);
  550.     } else {
  551.     totPercent = 0;
  552.     }
  553.     if (totFaults > 0) {
  554.     quickPercent = 100.0 * ((float)diffStat.quickCOWFaults / totFaults);
  555.     } else {
  556.     quickPercent = 0;
  557.     }
  558.     fprintf(stream, 
  559.         "COW: Heap (%d/%d)=%d%% Stk (%d/%d)=%d%% Tot (%d/%d)=%d%%\n",
  560.         diffStat.numCOWHeapFaults, diffStat.numCOWHeapPages, heapPercent,
  561.         diffStat.numCOWStkFaults, diffStat.numCOWStkPages, stkPercent,
  562.         totFaults, totPages, totPercent);
  563.     fprintf(stream, "     Quick (%d/%d)=%d%%\n",
  564.         diffStat.quickCOWFaults, totFaults, quickPercent);
  565.     /*
  566.      * Copy on reference.
  567.      */
  568.     totPages = diffStat.numCORStkPages + diffStat.numCORHeapPages;
  569.     totFaults = diffStat.numCORStkFaults + diffStat.numCORHeapFaults;
  570.     if (diffStat.numCORHeapPages > 0) {
  571.     heapPercent = 100.0 * ((float)diffStat.numCORHeapFaults / 
  572.                       diffStat.numCORHeapPages);
  573.     } else {
  574.     heapPercent = 0;
  575.     }
  576.     if (diffStat.numCORStkPages > 0) {
  577.     stkPercent = 100.0 * ((float)diffStat.numCORStkFaults / 
  578.                       diffStat.numCORStkPages);
  579.     } else {
  580.     stkPercent = 0;
  581.     }
  582.     if (totPages > 0) {
  583.     totPercent = 100.0 * ((float)totFaults / totPages);
  584.     } else {
  585.     totPercent = 0;
  586.     }
  587.     fprintf(stream,
  588.             "COR: Heap (%d/%d)=%d%% Stk (%d/%d)=%d%% Tot (%d/%d)=%d%%\n",
  589.         diffStat.numCORHeapFaults, diffStat.numCORHeapPages, heapPercent,
  590.         diffStat.numCORStkFaults, diffStat.numCORStkPages, stkPercent,
  591.         totFaults, totPages, totPercent);
  592.     totPages = diffStat.numCORStkFaults + diffStat.numCORHeapFaults;
  593.     totFaults = diffStat.numCORCOWStkFaults + diffStat.numCORCOWHeapFaults;
  594.     if (diffStat.numCORCOWHeapFaults > 0) {
  595.     heapPercent = 100.0 * ((float)diffStat.numCORCOWHeapFaults / 
  596.                       diffStat.numCORHeapFaults);
  597.     } else {
  598.     heapPercent = 0;
  599.     }
  600.     if (diffStat.numCORCOWStkFaults > 0) {
  601.     stkPercent = 100.0 * ((float)diffStat.numCORCOWStkFaults / 
  602.                       diffStat.numCORStkFaults);
  603.     } else {
  604.     stkPercent = 0;
  605.     }
  606.     if (totPages > 0) {
  607.     totPercent = 100.0 * ((float)totFaults / totPages);
  608.     } else {
  609.     totPercent = 0;
  610.     }
  611.     fprintf(stream,
  612.             "COR-mod: Heap(%d/%d)=%d%% Stk (%d/%d)=%d%% Tot (%d/%d)=%d%%\n",
  613.         diffStat.numCORCOWHeapFaults, diffStat.numCORHeapFaults,heapPercent,
  614.         diffStat.numCORCOWStkFaults, diffStat.numCORStkFaults, stkPercent,
  615.         diffStat.numCORCOWHeapFaults + diffStat.numCORCOWStkFaults,
  616.         diffStat.numCORHeapFaults + diffStat.numCORStkFaults, totPercent);
  617.  
  618.     fprintf(stream, "Swap pages copied: %d\n", diffStat.swapPagesCopied);
  619.     fprintf(stream,
  620.              "Vm allocs: %d (Free=%d From-FS=%d From-alloc-list=%d)\n",
  621.          diffStat.numAllocs, diffStat.gotFreePage, diffStat.gotPageFromFS, 
  622.          diffStat.pageAllocs);
  623.     fprintf(stream, 
  624.          "VM-FS stats: Asked=%d Free-pages=%d Allocs=%d Frees=%d\n",
  625.          diffStat.fsAsked, diffStat.haveFreePage, diffStat.fsMap, 
  626.          diffStat.fsUnmap);
  627.     fprintf(stream, "Alloc-list searches: %d (Free=%d In-use=%d)\n",
  628.          diffStat.numListSearches, diffStat.usedFreePage, 
  629.          diffStat.numListSearches - diffStat.usedFreePage);
  630.     fprintf(stream, "Extra-searches: %d (Lock=%d Ref=%d Dirty=%d)\n",
  631.          diffStat.lockSearched + diffStat.refSearched + 
  632.          diffStat.dirtySearched,
  633.          diffStat.lockSearched, diffStat.refSearched, 
  634.          diffStat.dirtySearched);
  635.     fprintf(stream, "Pages written %d\n", diffStat.pagesWritten);
  636.  
  637.     totPrefetches = diffStat.codePrefetches + diffStat.heapFSPrefetches +
  638.             diffStat.heapSwapPrefetches + diffStat.stackPrefetches;
  639.     if (totPrefetches > 0) {
  640.     totHits = diffStat.codePrefetchHits + diffStat.heapFSPrefetchHits +
  641.           diffStat.heapSwapPrefetchHits + diffStat.stackPrefetchHits;
  642.     fprintf(stream, "Prefetch stats:\n");
  643.     if (diffStat.codePrefetches > 0) {
  644.         hitPct = 100 * ((float)diffStat.codePrefetchHits / 
  645.                 (float)diffStat.codePrefetches);
  646.         fprintf(stream, "    code (%d/%d)=%d%%\n",
  647.             diffStat.codePrefetchHits, diffStat.codePrefetches, hitPct);
  648.     }
  649.     if (diffStat.heapFSPrefetches > 0) {
  650.         hitPct = 100 * ((float)diffStat.heapFSPrefetchHits / 
  651.                 (float)diffStat.heapFSPrefetches);
  652.         fprintf(stream, "    heap-fs (%d/%d)=%d%%\n",
  653.         diffStat.heapFSPrefetchHits, diffStat.heapFSPrefetches, hitPct);
  654.     }
  655.     if (diffStat.heapSwapPrefetches > 0) {
  656.         hitPct = 100 * ((float)diffStat.heapSwapPrefetchHits / 
  657.                 (float)diffStat.heapSwapPrefetches);
  658.         fprintf(stream, "    heap-swp (%d/%d)=%d%%\n",
  659.         diffStat.heapSwapPrefetchHits, diffStat.heapSwapPrefetches, 
  660.         hitPct);
  661.     }
  662.     if (diffStat.stackPrefetches > 0) {
  663.         hitPct = 100 * ((float)diffStat.stackPrefetchHits / 
  664.                 (float)diffStat.stackPrefetches);
  665.         fprintf(stream, "    stack (%d/%d)=%d%%\n",
  666.         diffStat.stackPrefetchHits, diffStat.stackPrefetches, hitPct);
  667.     }
  668.     hitPct = 100 * ((float)totHits / (float)totPrefetches);
  669.     fprintf(stream, "    total (%d/%d)=%d%%\n",
  670.         totHits, totPrefetches, hitPct);
  671.     fprintf(stream, "    aborts=   %d\n", diffStat.prefetchAborts);
  672.     }
  673.  
  674.     fprintf(stream, "Contexts stolen %d pmegs stolen %d\n",
  675.          diffStat.machDepStat.stealContext, diffStat.machDepStat.stealPmeg);
  676. }
  677. @
  678.  
  679.  
  680. 1.1
  681. log
  682. @Initial revision
  683. @
  684. text
  685. @d6 9
  686. a14 9
  687. #include "sprite.h"
  688. #include "status.h"
  689. #include "io.h"
  690. #include "proc.h"
  691. #include "vm.h"
  692. #include "kernel/fs.h"
  693. #include "kernel/fsStat.h"
  694. #include "kernel/sched.h"
  695. #include "kernel/vm.h"
  696. d35 1
  697. a35 1
  698.     Io_Stream stream;
  699. d43 1
  700. a43 1
  701.     Io_PrintStream(stream, "%d.%03du ", delta.seconds,
  702. d47 1
  703. a47 1
  704.     Io_PrintStream(stream, "%d.%03ds ", delta.seconds,
  705. d53 1
  706. a53 1
  707.         Io_PrintStream(stream, "%d:", seconds / 3600);
  708. d57 1
  709. a57 1
  710.         Io_PrintStream(stream, "%d:", seconds / 60);
  711. d60 1
  712. a60 1
  713.     Io_PrintStream(stream, "%d.%03d", seconds,
  714. d63 1
  715. a63 1
  716.     Io_PrintStream(stream, "\n");
  717. d86 1
  718. a86 1
  719.     Io_Stream stream;
  720. d95 1
  721. a95 1
  722.     Byte_Zero(sizeof(Sched_Instrument), &zeroStats);
  723. d98 4
  724. a101 3
  725.     highTicks = endSchedPtr->idleTicksOverflow -
  726.         startSchedPtr->idleTicksOverflow;
  727.     lowTicks = endSchedPtr->idleTicksLow - startSchedPtr->idleTicksLow;
  728. d104 1
  729. a104 1
  730.     Io_PrintStream(stream, "(High ticks = %d)", highTicks);
  731. d107 1
  732. a107 1
  733.     Io_PrintStream(stream, "Idle ticks --/-- = 100%% Idle, Elapsed time ");
  734. d111 1
  735. a111 1
  736.     Io_PrintStream(stream, "Idle ticks %0.0f/%d = %6.2f%% Idle, Context Sw. %d inv %d full %d, Elapsed time ",
  737. d113 9
  738. a121 5
  739.            endSchedPtr->idleTicksPerSecond,
  740.            (double)lowTicks/(double)endSchedPtr->idleTicksPerSecond * 100.,
  741.            endSchedPtr->numContextSwitches - startSchedPtr->numContextSwitches,
  742.            endSchedPtr->numInvoluntarySwitches - startSchedPtr->numInvoluntarySwitches,
  743.            endSchedPtr->numFullCS - startSchedPtr->numFullCS);
  744. d148 1
  745. a148 1
  746.     Io_Stream stream;    /* Output stream */
  747. d157 1
  748. a157 1
  749.     Byte_Zero(sizeof(FsStats), &zeroStats);
  750. d163 1
  751. a163 1
  752.     Io_PrintStream(stream, "Cache blocks max %d min %d number %d/%d free %d/%d limit %d\n",
  753. d180 1
  754. a180 1
  755.     Io_PrintStream(stream, "Bytes read %d+%d remote %d disk %d+%d",
  756. d183 1
  757. a183 2
  758. #ifdef stupid_compiler
  759.     Io_PrintStream(stream, "\ttraffic ratio %%%d\n",
  760. a184 3
  761. #else
  762.     Io_PrintStream(stream, "\n");
  763. #endif
  764. d186 1
  765. a186 1
  766.     Io_PrintStream(stream, "\n");
  767. d200 1
  768. a200 1
  769.     Io_PrintStream(stream, "Bytes written %d+%d remote %d disk %d+%d",
  770. a201 1
  771. #ifdef stupid_compiler
  772. d203 1
  773. a203 1
  774.     Io_PrintStream(stream, "\ttraffic ratio %%%d",
  775. d206 1
  776. a206 2
  777. #endif
  778.     Io_PrintStream(stream, "\n");
  779. d214 1
  780. a214 1
  781.     Io_PrintStream(stream, "Dev bytes read %d written %d\n", t1, t2);
  782. d221 1
  783. a221 1
  784.     Io_PrintStream(stream, "Zero Fills read %d write1 %d write2 %d frag %d\n",
  785. d227 1
  786. a227 1
  787.     Io_PrintStream(stream, "Appends %d Overwrites %d Failed Reads %d\n",
  788. d243 1
  789. a243 1
  790.     Io_PrintStream(stream, "Cache reads %d hits: dirty %d clean %d other %d",
  791. a244 1
  792. #ifdef stupid_compiler
  793. d246 1
  794. a246 1
  795.     Io_PrintStream(stream, "\thit ratio %%%d",
  796. d249 1
  797. a249 2
  798. #endif
  799.     Io_PrintStream(stream, "\n");
  800. d256 1
  801. a256 1
  802.     Io_PrintStream(stream, "Read Ahead: hits %d/%d all-in-cache %d/%d\n",
  803. d270 1
  804. a270 1
  805.     Io_PrintStream(stream, "Cache writes %d hits %d misses %d thru %d",
  806. a271 1
  807. #ifdef stupid_compiler
  808. d273 1
  809. a273 1
  810.     Io_PrintStream(stream, "\ttraffic ratio %%%d",
  811. d276 1
  812. a276 2
  813. #endif
  814.     Io_PrintStream(stream, "\n");
  815. d278 1
  816. a278 1
  817.     Io_PrintStream(stream, "Write thru %d data %d indirect %d desc %d dir %d\n",
  818. d289 1
  819. a289 1
  820.     Io_PrintStream(stream, "File descriptor reads %d hits %d writes %d hits %d\n",
  821. d300 1
  822. a300 1
  823.     Io_PrintStream(stream, "Indirect block reads %d hits %d writes %d\n",
  824. d309 1
  825. a309 1
  826.     Io_PrintStream(stream, "Directory block reads %d hits %d writes %d\n",
  827. d318 1
  828. a318 1
  829.     Io_PrintStream(stream, "VM requests %d tried %d gave %d\n",
  830. d326 1
  831. a326 1
  832.     Io_PrintStream(stream, "Cache blocks created %d, alloc from free %d part %d lru %d\n",
  833. d336 1
  834. a336 1
  835.     Io_PrintStream(stream, "Disk blocks alloc %d free %d search %d/%d hash %d\n",
  836. d347 1
  837. a347 1
  838.     Io_PrintStream(stream, "Fragments alloc %d free %d upgrade %d blocks made %d used %d, bad hints %d\n",
  839. d362 1
  840. a362 1
  841.     Io_PrintStream(stream, "Name cache entries %d accesses %d hits %d replaced %d\n",
  842. d371 1
  843. a371 1
  844.     Io_PrintStream(stream, "Handles %d created %d installed %d hits %d old %d version %d flush %d\n",
  845. d379 1
  846. a379 2
  847.                end->handle.oldHandles -
  848.                start->handle.oldHandles,
  849. d384 1
  850. a384 1
  851.     Io_PrintStream(stream, "\tfetched %d hits %d released %d locks %d/%d wait %d\n",
  852. d389 2
  853. a390 4
  854.                end->handle.releaseCalls -
  855.                start->handle.releaseCalls,
  856.                end->handle.lockCalls -
  857.                start->handle.lockCalls,
  858. d393 2
  859. d397 1
  860. a397 1
  861.     Io_PrintStream(stream, "Segments fetched %d hits %d\n",
  862. d402 1
  863. a402 1
  864.     Io_PrintStream(stream, "Lookup relative %d absolute %d redirect %d found %d loops %d timeouts %d stale %d\n",
  865. d441 1
  866. a441 1
  867.     Io_Stream stream;    /* Output stream */
  868. d473 1
  869. a473 1
  870.     Io_PrintStream(stream, "Kernel VM Pages: %d (Code+Data=%d Stacks=%d)\n",
  871. d478 1
  872. a478 1
  873.     Io_PrintStream(stream, "User VM Pages:   %d (Free=%d Dirty=%d Res=%d Alloc-list=%d)\n",
  874. d484 1
  875. a484 1
  876.     Io_PrintStream(stream, "Modified pages: Total=%d %%Tot-dirty=%0.2f %%Inuse-dirty=%0.2f\n",
  877. d488 1
  878. a488 1
  879.     Io_PrintStream(stream, "FS Pages: Current=%d Max=%d Min=%d\n", 
  880. d490 1
  881. a490 1
  882.     Io_PrintStream(stream,
  883. d494 1
  884. a494 1
  885.     Io_PrintStream(stream, "        %8d (Code=%d Heap=%d Stack=%d)\n", 
  886. d497 1
  887. a497 1
  888.     Io_PrintStream(stream, 
  889. d529 1
  890. a529 1
  891.     Io_PrintStream(stream, 
  892. d534 1
  893. a534 1
  894.     Io_PrintStream(stream, "     Quick (%d/%d)=%d%%\n",
  895. d558 1
  896. a558 1
  897.     Io_PrintStream(stream,
  898. d582 1
  899. a582 1
  900.     Io_PrintStream(stream,
  901. d589 2
  902. a590 2
  903.     Io_PrintStream(stream, "Swap pages copied: %d\n", diffStat.swapPagesCopied);
  904.     Io_PrintStream(stream,
  905. d594 1
  906. a594 1
  907.     Io_PrintStream(stream, 
  908. d598 1
  909. a598 1
  910.     Io_PrintStream(stream, "Alloc-list searches: %d (Free=%d In-use=%d)\n",
  911. d601 1
  912. a601 1
  913.     Io_PrintStream(stream, "Extra-searches: %d (Lock=%d Ref=%d Dirty=%d)\n",
  914. d606 1
  915. a606 1
  916.     Io_PrintStream(stream, "Pages written %d\n", diffStat.pagesWritten);
  917. d613 1
  918. a613 1
  919.     Io_PrintStream(stream, "Prefetch stats:\n");
  920. d617 1
  921. a617 1
  922.         Io_PrintStream(stream, "    code (%d/%d)=%d%%\n",
  923. d623 1
  924. a623 1
  925.         Io_PrintStream(stream, "    heap-fs (%d/%d)=%d%%\n",
  926. d629 1
  927. a629 1
  928.         Io_PrintStream(stream, "    heap-swp (%d/%d)=%d%%\n",
  929. d636 1
  930. a636 1
  931.         Io_PrintStream(stream, "    stack (%d/%d)=%d%%\n",
  932. d640 1
  933. a640 1
  934.     Io_PrintStream(stream, "    total (%d/%d)=%d%%\n",
  935. d642 1
  936. a642 1
  937.     Io_PrintStream(stream, "    aborts=   %d\n", diffStat.prefetchAborts);
  938. d645 1
  939. a645 1
  940.     Io_PrintStream(stream, "Contexts stolen %d pmegs stolen %d\n",
  941. @
  942.